let inputName = document.querySelector(".input-name input")

let inputTel = document.querySelector(".input-tel input")

let captcha = document.querySelector(".captcha input")

let inputPassword = document.querySelector(".input-password input")
let textName = document.querySelector(".name")
let textTel = document.querySelector(".tel")
let testCaptcha = document.querySelector(".tel-captcha")
let textPassword = document.querySelector(".password")
let btn = document.querySelector(".captcha button")
let time = 60
let btnDisabled = document.querySelector(".captcha a")
window.addEventListener("load",function(){
    if(inputTel.value.length!=11){
        btn.disabled = true
    }else{
        btn.disabled = false
        btnDisabled.style.display = "none"
    }
})
btnDisabled.addEventListener("click",function(){
    if(inputTel.value.length!=11){
        textTel.style.display = "block"
    }else if(inputTel.value.length==11){
        textTel.style.display = "none"
        
    }
    
})
inputName.addEventListener("blur", function () {
    if (inputName.value.length < 6 || inputName.value.length > 12) {
        textName.style.display = "block"
    } else if (inputName.value.length >= 6 && inputName.value.length <= 12) {
        textName.style.display = "none"
    }
})
inputTel.addEventListener("blur", function () {
    if (inputTel.value.length != 11) {
        textTel.style.display = "block"

    } else if (inputTel.value.length == 11) {
        textTel.style.display = "none"
        btnDisabled.style.display = "none"
    }
})

captcha.addEventListener("blur", function () {
    if (captcha.value.length != 4) {
        testCaptcha.style.display = "block"
        
    } else if (captcha.value.length == 4) {
        testCaptcha.style.display = "none"
        
    }
})
inputPassword.addEventListener("blur", function () {
    if (inputPassword.value.length < 6 || inputPassword.value.length > 12) {
        textPassword.style.display = "block"
    } else if (inputPassword.value.length >= 6 && inputPassword.value.length <= 12) {
        textPassword.style.display = "none"
    }
})
btn.addEventListener("click",function(){
    
    let t = setInterval(function () {
        time--
        btn.innerHTML = time + "秒"
        
        if (time == 0) {
            clearInterval(t)
            time = 60
            btn.innerHTML = time + "秒"
        } else {
            btn.disabled = true
        }
        
    }, 1000)
})
